package com.qws.xprinter.flutter_xprinter.utils;

import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;

import net.posprinter.model.PTable;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class Utils {

    public static PTable addRow(PTable table, List<List<String>> rows) {
        for (List<String> row : rows) {
            table.addRow(row.toArray(new String[row.size()]));
        }
        return table;
    }

    public static UsbDevice getUsbDeviceFromName(Context context, String usbName) {
        UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
        HashMap<String, UsbDevice> usbDeviceList = usbManager.getDeviceList();
        return usbDeviceList.get(usbName);
    }

}
